package com.server.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.server.entity.MayDayTagClass;
import com.server.example.MayDayTagClassExample;
import com.server.mapper.MayDayTagClassMapper;
import org.apache.ibatis.session.SqlSession;
import until.MybatisClass;

import java.util.List;

public class MayDayTagController {
    /**
     * > Return all the information in the table
     * @return select * form mayday_tag
     */
    public PageInfo<MayDayTagClass> getAll(int pageNumber, int pageSize){
        PageHelper.startPage(pageNumber, pageSize);
        PageInfo<MayDayTagClass> mayDayTagClasses = null;
        SqlSession sqlSession = MybatisClass.getSqlSession();
        MayDayTagClassMapper mayDayTagClassMapper = sqlSession.getMapper(MayDayTagClassMapper.class);
        MayDayTagClassExample mayDayTagClassExample=new MayDayTagClassExample();
        try {
            mayDayTagClassExample.createCriteria().andIdIsNotNull();
            mayDayTagClasses = new PageInfo<>(mayDayTagClassMapper.selectByExample(mayDayTagClassExample));
            return mayDayTagClasses;
        }catch (Exception e) {
            e.printStackTrace();
        }finally {
            sqlSession.close();
        }
        return mayDayTagClasses;
    }
}
